package com.SouthernWall_404.AgeRight.Common.Event;

import com.SouthernWall_404.AgeRight.Common.API.LockAPI.LockableBlocksRegistry;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.IModBusEvent;

import java.util.function.BiConsumer;
import java.util.function.Consumer;

/**
 * 允许其他模组注册可锁定方块的事件
 */
public class RegisterLockableBlocksEvent extends Event implements IModBusEvent {
    private final Consumer<Block> blockRegistrar;
    private final Consumer<TagKey<Block>> tagRegistrar;
    private final BiConsumer<ResourceLocation, LockableBlocksRegistry.LockableCondition> conditionRegistrar;
    
    public RegisterLockableBlocksEvent(
            Consumer<Block> blockRegistrar,
            Consumer<TagKey<Block>> tagRegistrar,
            BiConsumer<ResourceLocation, LockableBlocksRegistry.LockableCondition> conditionRegistrar) {
        this.blockRegistrar = blockRegistrar;
        this.tagRegistrar = tagRegistrar;
        this.conditionRegistrar = conditionRegistrar;
    }
    
    public void register(Block block) {
        blockRegistrar.accept(block);
    }
    
    public void register(TagKey<Block> tag) {
        tagRegistrar.accept(tag);
    }
    
    public void register(ResourceLocation id, LockableBlocksRegistry.LockableCondition condition) {
        conditionRegistrar.accept(id, condition);
    }
    
    // 简化方法 - 使用模组ID和路径创建ResourceLocation
    public void register(String modId, String path, LockableBlocksRegistry.LockableCondition condition) {
        register(new ResourceLocation(modId, path), condition);
    }
}